package com.yfqy.admin.enums;

import lombok.Getter;

@Getter
public enum ResponseEnum {
    // 成功
    SUCCESS(0, "操作成功"),
    BAD_REQUEST(400, "Bad Request"),
    // 登录
    NEED_LOGIN(401, "需要登录后操作"),
    SIGN_ERROR(402, "签名错误"),
    NO_OPERATOR_AUTH(403, "无权限操作"),
    NOT_FOUND(404, "资源不存在"),
    METHOD_NOT_ALLOWED(405, "Method Not Allowed"),
    SYSTEM_ERROR(500, "出现错误"),
    USERNAME_EXIST(501, "用户名已存在，不可重复添加"),
    PHONE_NUMBER_EXIST(502, "手机号已存在，不可重复添加"),
    EMAIL_EXIST(503, "邮箱已存在，不可重复添加"),
    REQUIRE_USERNAME(504, "必需填写用户名"),
    LOGIN_ERROR(505, "用户名或密码错误"),
    USER_IS_INVALID(507, "无效的用户"),
    USER_NOT_EXIST(506, "用户不存在"),
    USERNAME_NOT_NULL(508, "用户名不能为空"),
    NICKNAME_NOT_NULL(509, "昵称不能为空"),
    PASSWORD_NOT_NULL(510, "密码不能为空"),
    EMAIL_NOT_NULL(511, "邮箱不能为空"),
    NICKNAME_EXIST(512, "昵称已存在"),
    CATEGORY_IS_INVALID(520, "无效的商品类目"),
    CATEGORY_IS_EXIST(521, "商品类目已存在，不可重复添加"),
    CATEGORY_LEVEL_NOT_EXIST(522, "商品类目级别不存在"),
    CATEGORY_LEVEL2_ICON_NOT_NULL(523, "二级类目图标不能为空"),
    CATEGORY_LEVEL2_NEED_LEVEL1(524, "创建二级分类需要选择一级分类"),
    CATEGORY_PARENT_NOT_EXIT(524, "父级分类不存在"),

    ATTRIBUTE_NOT_EXIT(540, "属性校验失败"),

    UER_NO_ROLE(600, "用户尚未分配角色"),
    ROLE_EXIST(601, "角色已存在，不可重复添加"),
    ROLE_NOT_EXIST(602, "角色不存在"),
    ROLE_NOTEXIST_INVALID(603, "角色不存在或已删除"),
    ROLE_CANNOT_DELETE(603, "此角色不可以删除"),
    MENU_URL_ISNULL(701, "菜单URL不能为空"),
    MENU_CODE_ISNULL(701, "权限code不能为空"),
    MENU_NOT_EXIST(702, "菜单不存在"),
    MENU_CODE_IS_EXIST(703, "权限编码已存在"),
    MENU_CANNOT_DELETE(704, "请先删除子菜单"),

    BRAND_IS_EXIT(800, "品牌已添加，不可重复添加"),
    BRAND_IS_INVALID(801, "品牌不存在或无效"),

    REVENUE_IS_INVALID(901, "收入记录不存在"),
    ;

    ResponseEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    private final Integer code;

    private final String message;


    public static ResponseEnum getExcEnum(Integer code) {
        for (ResponseEnum excEnum : ResponseEnum.values()) {
            if (excEnum.getCode().equals(code)) {
                return excEnum;
            }
        }
        return null;
    }
}
